package com.xqgl.servlet;

import java.io.IOException;
import java.sql.SQLException;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.xqgl.bean.Seat;
import com.xqgl.service.SeatDaoImp;

/**
 * Servlet implementation class addSeatServlet
 */
@WebServlet("/addSeatServlet")
public class addSeatServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    /**
     * @see HttpServlet#HttpServlet()
     */
    public addSeatServlet() {
        super();
        // TODO Auto-generated constructor stub
    }

	/**
	 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		request.setCharacterEncoding("utf-8");
		response.setContentType("text/html;Charset=utf-8");
		String villagename = request.getParameter("villagename");
		String seatnum = request.getParameter("seatnum");
		String carnum = request.getParameter("carnum");
		String carpicture = request.getParameter("carpicture");
		String username = request.getParameter("username");
		int userphone = Integer.parseInt(request.getParameter("userphone"));
		String nature = request.getParameter("nature");
		String totalcost = request.getParameter("totalcost");
		String starttime = request.getParameter("starttime");
		String deadline = request.getParameter("deadline");
		String seatctime = request.getParameter("seatctime");
		Seat seat = new Seat();
		seat.setVillagename(villagename);
		seat.setSeatnum(seatnum);
		seat.setCarnum(carnum);
		seat.setCarpicture(carpicture);
		seat.setUsername(username);
		seat.setUserphone(userphone);
		seat.setNature(nature);
		seat.setTotalcost(totalcost);
		seat.setStarttime(starttime);
		seat.setDeadline(deadline);
		seat.setSeatctime(seatctime);
		SeatDaoImp imp = new SeatDaoImp();
		try {
			imp.add(seat);
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		response.sendRedirect("seatlist.jsp");
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
